package cn.tedu._06interceptor.config;

import cn.tedu._06interceptor.interceptors.MyInterceptorl;
import cn.tedu._06interceptor.interceptors.Mylnterceptor2;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //1.拦截所有请求
        // registry.addInterceptor(new MyInterceptorl());
        //2.策略2：拦截指定请求,比如:只拦截登录请求和注册请求;
        //registry.addInterceptor(new MyInterceptorl())
        //    .excludePathPatterns("/v1/users/login","/v1/users/reg");
//      //3.策略3：拦截指定的一类请求,比如:拦截用户模块的所有请求[两个星**];
//        registry.addInterceptor(new MyInterceptorl())
//                .addPathPatterns("/v1/users/**");
        //4.策略4：排除指定的请求,比如：拦截除了登录功能之外的所有请求;
        // registry.addInterceptor(new MyInterceptorl())
        //  .excludePathPatterns("/v1/usesrs/login");
        //5.策略5：拦截用户模块中除了登录功能之外的所有请求;
//        registry.addInterceptor(new MyInterceptorl())
//                .addPathPatterns("/v1/users/**")
//        .excludePathPatterns("v1/users/login");

        //1.拦截所有请求

        registry.addInterceptor(new MyInterceptorl());
        registry.addInterceptor(new Mylnterceptor2());


    }
}
